home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / drdobbs / 1988 / 07 / bench / benchnew.tb < prev    next >
Text File  |  1988-04-29  |  2KB  |  85 lines

  1. [FILENAME:  BENCHNEW.TB]
  2.  
  3. DEFLNG A-Z
  4. DIM t!(28)
  5. OPEN "c:tbnew.tim" FOR OUTPUT AS #1
  6.  
  7. 'time for a raw long integer loop, executed 1,000,000 times.
  8. t! = TIMER
  9. FOR i = 1 TO 1000
  10.   FOR j = 1 TO 10
  11.   NEXT j
  12. NEXT i
  13. t!(0) = TIMER - t!
  14.  
  15. 'time for 1,000,000 long integer assignments.
  16. y = 5: z = -5
  17. t! = TIMER
  18. FOR i = 1 TO 1000
  19.   FOR j = 1 TO 10
  20.   x = y
  21.   x = z
  22.   NEXT j
  23. NEXT i
  24. t!(1) = (TIMER - t! - t!(0)) / 2
  25.  
  26. 'time for 1,000,000 long integer adds
  27. t! = TIMER
  28. FOR i = 1 TO 1000
  29.   FOR j = 1 TO 10
  30.   x = x + y
  31.   NEXT j
  32. NEXT i
  33. t!(2) = TIMER - t! - t!(1)
  34.  
  35. 'time for 1,000,000 long integer subtracts
  36. x = 0
  37. t! = TIMER
  38. FOR i = 1 TO 1000
  39.   FOR j = 1 TO 10
  40.   x = x - y
  41.   NEXT j
  42. NEXT i
  43. t!(3) = TIMER - t! - t!(1)
  44.  
  45. 'time for 1,000,000 long integer multiplies
  46. t! = TIMER
  47. FOR i = 1 TO 1000
  48.   FOR j = 1 TO 10
  49.   x = i * j
  50.   NEXT j
  51. NEXT i
  52. t!(4) = TIMER - t! - t!(1)
  53.  
  54. 'time for 1,000,000 long integer divides
  55. t! = TIMER
  56. FOR i = 1 TO 1000
  57.   FOR j = 1 TO 10
  58.   x = i \ j
  59.   NEXT j
  60. NEXT i
  61. t!(5) = TIMER - t! - t!(1)
  62.  
  63. 'following are logical comparisons and operators
  64.  
  65. 'time for 1,000,000 long integer comparisons
  66. x = 5: y = -5
  67. t! = TIMER
  68. FOR i = 1 TO 1000
  69.   FOR j = 1 TO 10
  70.     IF i < y THEN x = 1
  71.   NEXT j
  72. NEXT i
  73. t!(23) = TIMER - t! - t!(0)
  74.  
  75. 'print results of benchmark
  76. PRINT #1, "Raw long integer loop, 1,000,000 iterations:"; TAB(45); t!(0)*100
  77. PRINT #1, "1,000,000 long integer assignments:"; TAB(45); t!(1)*100
  78. PRINT #1, "1,000,000 long integer additions:"; TAB(45); t!(2)*100
  79. PRINT #1, "1,000,000 long integer subtractions:"; TAB(45); t!(3)*100
  80. PRINT #1, "1,000,000 long integer multiplications:"; TAB(45); t!(4)*100
  81. PRINT #1, "1,000,000 long integer divisions:"; TAB(45); t!(5)*100
  82. PRINT #1, "1,000,000 long integer comparisons:"; TAB(45); t!(23)*100
  83. END
  84.  
  85.